package app

import (
	"cli-desktop/proto"
	"cli-desktop/public"
)

/*
*  -*- coding:utf8 -*-
*
*   聊天相关
*
*  @Author  : chengms
*  @WebSite : chengms.com
*  @Email   : chengms2012@163.com
*  @TIME    : 2020/8/24 22:52
*  @File    : chat.go
 */

type ChatMsg struct {
	Target string
	data   []interface{}
}

func SendChatMSg(target string, msg string) (err error) {
	chatBuf := ChatMsg{Target: target}
	chatBuf.data = append(chatBuf.data, msg)

	sendCmd := proto.NewSendCommand(proto.CmdSend)
	err = sendCmd.SendCmd(chatBuf)
	if err != nil {
		public.Loggerf.Error(err)
		return
	}

	return
}
